
#delimit;
clear;
capture log close;
set more off;

global prog "C:\Your Directory";

log using "$prog\HCMR_Analysis.log", text replace;

/* User Written Commands */

ssc install maptile, replace;
ssc install spmap, replace;
maptile_install using http://files.michaelstepner.com/geo_state.zip, replace;
ssc install coefplot, replace;
ssc install estout, replace;
ssc install weakivtest, replace;
ssc install ivreg2, replace; 
ssc install avar;
ssc install ranktest, replace;
ssc inst egenmore, replace; 
ssc install grstyle, replace;
ssc install palettes, replace;
grstyle init;
grstyle set plain, horizontal grid;

/* Land Grant Maps */

use "$prog\LandGrantMaps.dta", clear;
rename bplace statename;
maptile lg, geo(state) fcolor(Greys)  cutvalues(3 4 5 7) ndfcolor(white) twopt(legend(lab(2 "3") lab(3 "4")lab(4 "5") lab(5 "7") lab(6 "8")));;
graph export "$prog\Figure4B.pdf", as(pdf) replace;

maptile univ1800, geo(state) fcolor(gs14 gs8 gs3) ndfcolor(white) nquantiles(2) twopt(legend(lab(2 "No") lab(3 "Yes")));
graph export "$prog\Figure4C.pdf", as(pdf) replace;

/* Education and Birth Place */

use "$prog\EducationBirth.dta", clear;

twoway (scatter state_hedu_num state_birth_num, mlcolor(navy) mcolor(%45) 
xlabel(4 5 8 10 15 18 19 20 21 22 23 24 25 28 29 36 39 40 42 44 45 46 47 49 50, 
alternate valuelabel labsize(vsmall) angle(horizontal)) 
ylabel(3 5 8 10 12 16 17 18 19 21 22 23 24 25 28 29 36 39 40 42 44 45 47 50, 
alternate valuelabel labsize(vsmall) angle(horizontal))) 
(lfit state_hedu_num state_birth_num, lcolor(red) lwidth(medium) lpattern(dash) 
ytitle(College State) xtitle(Birth State) legend(off)) 
(line state_birth_num state_birth_num, lcolor(gs10) lwidth(vthin) lpattern(solid) graphregion(fcolor(white) lcolor(white)));
graph export "$prog\Figure5.pdf", as(pdf) replace;

reg state_hedu_num state_birth_num, robust cluster(state_birth_num);

tab stateM;

tab gdivM;

/* Main Dataset 1930 and 1940 */

use "$prog\GeneralElectricMain", clear;

/* Matching Diagnostics */

graph bar (mean) matched if year==1940, over(level) blabel(bar) ytitle(Percent Matched) 
ylabel(0(20)80) blabel(total, format(%9.0f)) b1title("Level") graphregion(fcolor(white) 
lcolor(white)) bar(1, fcolor(gs10) lcolor(black));
graph export "$prog\FigureA2A.pdf", as(pdf) replace;

gen lens=strlen(last);
gen cinit=wordcount(middle);
replace cinit=1+cinit;
by last year, sort: gen common=_N;
reg matched lens cinit common if year==1940;

est clear;
reg matched ib6.level if year==1940, robust;
testparm i(1/5).level, equal;
est store match1;
reg matched ib6.level lens cinit common if year==1940, robust;
testparm i(1/5).level, equal;
est store match2;

coefplot (match1, ciopts(recast(rspike) mcolor(black)) label("No Controls")) 
(match2, ciopts(recast(rspike) color(gs10)) msymbol(S) label("Name Controls") mcolor(gs10)), 
vertical drop(_cons lens cinit common) ylabel(-40(10)20) yline(0, lcolor(red) 
lwidth(thin) lpattern(dash)) xlabel(1 "1" 2 "2" 3 "3" 4 "4" 5 "5") xtitle("Level") 
ytitle(Change in Match Rate) grid(between);
graph export "$prog\FigureA2B.pdf", replace;

/* Wages */

est clear;
reg lwage c.age##c.age hours weeks female immigrant, robust;
margins, at(age=(25(1)65)) post;
est store model1;

tobit lwage c.age##c.age hours weeks female immigrant, ul(8.517192);
margins, at(age=(25(1)65)) post;
est store model2;

coefplot 
(model1, noci recast(connected) lcolor(gs10) msymbol(th) mlwidth(thin) mcolor(black) label("OLS")) 
(model2, noci recast(connected) lcolor(gs10) msymbol(sh) mlwidth(thin) mcolor(black) label("Tobit")), 
keep(*._at) nooffsets vertical xlabel(1 "25" 6 "30" 11 "35" 16 "40" 21 "45" 
26 "50" 31 "55" 36 "60" 41 "65") xtitle("Age") ytitle(Log Wage);
graph export "$prog\Figure3.pdf", as(pdf) replace;

gen match_wage=matched;
replace match_wage=1 if match_wage==100;
replace match_wage=. if year==1930;
replace match_wage=. if match_wage==0;
replace match_wage=0 if wage==. & year==1940 & match_wage==1;
tab match_wage;

reg match_wage ib6.level if year==1940, robust;
testparm i(1/5).level, equal;
margins, dydx(i.level);
marginsplot, ciopts(recast(rspike)) recast(scatter) title(" ") xtitle(Level) ytitle(P)
xlabel(1 "1" 2 "2" 3 "3" 4 "4" 5 "5", labsize(medium)) ytitle(Probability of Wage Data) 
ylabel(, angle(horizontal)) yscale(titlegap(*-30))
graphregion(fcolor(white) lcolor(white)) yline(0, lcolor(red) 
lwidth(thin) lpattern(dash));
graph export "$prog\FigureA4.pdf", as(pdf) replace;

/* Structure of Hierarchy */

preserve;
gen ind=1;
collapse (count) ind, by(year level);
egen indT=sum(ind), by(year);
gen indS=ind/indT;
replace indS=indS*100;
replace indS = -indS if year==1930;
gen zero=0;

label define lev_lab 1 "Level 1" 2 "Level 2" 3 "Level 3" 4 "Level 4" 5 "Level 5" 6 "Level 6";
label values level lev_lab;

twoway (bar indS level if year==1930, yscale(reverse) horizontal bfc(gs7) blc(gs7)) 
(bar indS level if year==1940, horizontal bfc(gs11) blc(gs11)) 
scatter level zero, mlabel(level) mlabcolor(black) msymbol(none) 
xtitle("Percent of Employees") ytitle("Level") ytitle("") yscale(noline) ylabel(none) 
legend(off) text(2 -25 "1930") text(2 25 "1940") xlabel(-50 "50" -40 "40" -30 "30" -20 "20" -10 "10" 0(10)50);
graph export "$prog\Figure1A.pdf", as(pdf) replace;
restore;

reg lwage weeks hours level, robust;
reg lwage weeks hours ib6.level, robust;
margins, dydx(i.level);
marginsplot, ciopts(recast(rspike)) recast(scatter) title(" ") xtitle(Level) ytitle(Log Wages (Annual))
xlabel(1 "1" 2 "2" 3 "3" 4 "4" 5 "5", labsize(medium)) 
graphregion(fcolor(white) lcolor(white));
graph export "$prog\Figure1B.pdf", as(pdf) replace;

/* Departments */

encode org, gen (org_lbled);
histogram org_lbled if year==1940, xlabel(1(1)8, labsize(small) angle(45) valuelabel) 
discrete frequency fcolor(gs10) lcolor(black) 
addlabel ylabel(, labels valuelabel) ytitle("") xtitle("") ylabel(0(250)1000) 
legend(off) graphregion(fcolor(white) lcolor(white));
graph export "$prog\FigureA1.pdf", as(pdf) replace;

/* Years of Education */

reg yschc40 c.age##c.age female immigrant if year==1940, robust;
margins, at(age=(25(1)65));
marginsplot, plot1opts(lcolor(gs10) msymbol(oh) mlwidth(thin) mcolor(black)) 
noci ylabel(10(1)17) xlabel(25(5)65) xtitle(Age) ytitle(Years of Education) title("") 
graphregion(fcolor(white) lcolor(white));
graph export "$prog\FigureA3.pdf", as(pdf) replace;

kdensity yschc40 if year==1940, ylabel(0(0.05)0.3) ytitle(Density) 
xtitle(Years of Education) xlabel(0(1)17) title("") caption("") note("") 
graphregion(fcolor(white) lcolor(white)) 
xline(8 12 16, lpattern(dash) lwidth(vthin) lcolor(red)) 
text(.28 6 "Elementary School", size(small) color(blue)) 
text(.28 10.7 "High School", size(small) color(blue)) 
text(.28 14.3 "College (4yr)", size(small) color(blue));
graph export "$prog\Figure2.pdf", as(pdf) replace;

/* Drop 1930 and Women */

drop if female==1;
keep if year==1940;

/* Birthplace Map */

preserve;
keep if year==1940;
gen ind=1;
collapse (sum) ind, by(state2 state);
drop if state2==".";
egen ind2=sum(ind);
gen ind3=(ind/ind2)*100;
rename (state state2) (statename state);
maptile ind, geo(state) fcolor(Greys) ndfcolor(white) nquantiles(6);
graph export "$prog\Figure4A.pdf", as(pdf) replace;
restore;

/* Locals and Control Variables */

local controls_ses "mard child immigrant hown";
local tvars "age mard child immigrant hown n_sch e_sch m_sch h_sch college collegeB yschc40 collyrs upper span1 span2 span3 weeks hours 
wage wageW nonwageD cg2 cg in1930";

/* Cohorts */

gen birthX=birth;
replace birthX=1940-age if birthX==.;

xtile quart=birthX, nq(4);

tabstat age, by(quart) s(mean median min max);

/* Labels */

label variable age "Age";
label variable mard "Married = 1";
label variable child "Number of Children";
label variable immigrant "Immigrant = 1";
label variable hown "Homeowner = 1";
label variable n_sch "No Schooling = 1";
label variable e_sch "Elementary School = 1";
label variable m_sch "Middle School = 1";
label variable h_sch "High School = 1";
label variable college "College = 1";
label variable collegeB "College (4+ years) = 1";
label variable yschc40 "Years of Education";
label variable collyrs "Years of Education if College = 1";
label variable upper "Upper = 1";
label variable span1 "Span of Control (overall)";
label variable span2 "Span of Control (next level)";
label variable span3 "Span of Control (next level same department)";
label variable weeks "Weeks Worked";
label variable hours "Hours Worked";
label variable wage "Annual Wage";
label variable wageW "Weekly Wage";
label variable lwageW "Log Wage";
label variable lwage_impW "Log Wage Imputed";
label variable nonwageD "Non-wage Income = 1";
label variable cg2 "Management Training = 1";
label variable cg "Management Training (frequency)";
label variable in1930 "Employed GE in 1930 = 1 ";

label variable lg "Land Grant College";
label variable univ1800 "University<1800";

/* Descriptives */

est clear;
estpost sum `tvars', meanonly;
est store aobs;
estpost sum `tvars' if upper==1, meanonly;
est store uobs;
estpost sum `tvars' if upper==0, meanonly;
est store lobs;

esttab aobs uobs lobs using "$prog\Table1.csv", cells("mean") keep(`tvars') label replace;

/* Specifying the Instrument */

local iv "lg univ1800"; /* Main instruments */

gen lgXpexp=lg*pexp;
gen lgXmard=lg*mard;
gen lgXchild=lg*child;
gen lgXhown=lg*hown;

gen univ1800Xpexp=univ1800*pexp; /* Include also interactions between SES variables and instrument */
gen univ1800Xmard=univ1800*mard;
gen univ1800Xchild=univ1800*child;
gen univ1800Xhown=univ1800*hown;

local iv_int "lg univ1800 lgXpexp lgXmard lgXchild lgXhown 
univ1800Xpexp univ1800Xmard univ1800Xchild univ1800Xhown"; 

/* First Stage Subsample Analysis */

egen group1=xtile(age) if yschc40~=., n(2);
recode group1 (1=2) (2=1);
egen group2=xtile(pexp) if yschc40~=., n(2);
recode group2 (1=2) (2=1);
egen group3=xtile(child) if yschc40~=., n(2);
recode group3 (1=2) (2=1);

gen group4=mard;
recode group4 (0=2);
gen group5=hown;
recode group5 (0=2);

tabstat age, by(group1) s(mean max min);
tabstat pexp, by(group2) s(mean max min);
tabstat child, by(group3) s(mean max min);
tabstat mard, by(group4) s(mean max min);
tabstat hown, by(group5) s(mean max min);

est clear;
forvalues i=1/5 {;
	eststo: reg yschc40 `iv' c.pexp##c.pexp in1930 i.org_code `controls_ses' if yschc40~=. & group`i'==1, robust cluster(bplace);
	eststo: reg yschc40 `iv' c.pexp##c.pexp in1930 i.org_code `controls_ses' if yschc40~=. & group`i'==2, robust cluster(bplace);
	eststo: reg college `iv' c.pexp##c.pexp in1930 i.org_code `controls_ses' if yschc40~=. & group`i'==1, robust cluster(bplace);
	eststo: reg college `iv' c.pexp##c.pexp in1930 i.org_code `controls_ses' if yschc40~=. & group`i'==2, robust cluster(bplace);
	};

esttab using "$prog\TableA1.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(lg univ1800) label nogaps replace;

/* Upper Levels of Hierarchy */

est clear;
eststo: reg upper c.pexp##c.pexp yschc40 if yschc40~=., robust;
estadd ysumm;
eststo: reg upper c.pexp##c.pexp yschc40 in1930 if yschc40~=., robust;
estadd ysumm;
eststo: reg upper c.pexp##c.pexp yschc40 in1930 i.org_code if yschc40~=., robust;
estadd ysumm;
eststo: reg upper c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;
eststo: reg upper c.pexp##c.pexp college if yschc40~=., robust;
estadd ysumm;
eststo: reg upper c.pexp##c.pexp college in1930 if yschc40~=., robust;
estadd ysumm;
eststo: reg upper c.pexp##c.pexp college in1930 i.org_code if yschc40~=., robust;
estadd ysumm;
eststo: reg upper c.pexp##c.pexp college in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;

esttab using "$prog\Table2PanelA.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(yschc40 college) label scalars(r2 N ymean) replace;

/* Upper Levels of Hierarchy 2SLS */

est clear;
eststo ivr1: ivreg2 upper c.pexp##c.pexp (yschc40=`iv') if yschc40~=., cluster(bplace) first savefirst savefprefix(fst1);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr2: ivreg2 upper c.pexp##c.pexp (yschc40=`iv') in1930 if yschc40~=., cluster(bplace) first savefirst savefprefix(fst2);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr3: ivreg2 upper c.pexp##c.pexp (yschc40=`iv') in1930 i.org_code if yschc40~=., cluster(bplace) first savefirst savefprefix(fst3);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr4: ivreg2 upper c.pexp##c.pexp (yschc40=`iv') in1930 i.org_code `controls_ses' if yschc40~=., cluster(bplace) first savefirst savefprefix(fst4);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr5: ivreg2 upper c.pexp##c.pexp (college=`iv') if yschc40~=., cluster(bplace) first savefirst savefprefix(fst5);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr6: ivreg2 upper c.pexp##c.pexp (college=`iv') in1930 if yschc40~=., cluster(bplace) first savefirst savefprefix(fst6);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr7: ivreg2 upper c.pexp##c.pexp (college=`iv') in1930 i.org_code if yschc40~=., cluster(bplace) first savefirst savefprefix(fst7);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr8: ivreg2 upper c.pexp##c.pexp (college=`iv') in1930 i.org_code `controls_ses' if yschc40~=., cluster(bplace) first savefirst savefprefix(fst8);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

esttab ivr* fst* using "$prog\Table2PanelB.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(yschc40 college `iv') 
label scalars(r2 N ymean MF J) sfmt(%9.3fc %9.0fc %9.3fc %9.1fc %9.3fc) replace;

/* Upper Levels of Hierarchy Robustness */

est clear;
eststo: probit upper c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;
eststo: margins, dydx(*) post;
eststo: reg upper c.pexp##c.pexp##c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;
eststo: reg upper c.age##c.age yschc40 in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;
eststo: reg upper c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' if yschc40~=. & immigrant==0, robust;
estadd ysumm;
reg upper c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' if yschc40~=.;
predict out2 if e(sample), cooksd;
gen obs=e(N);
eststo: reg upper c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' if yschc40~=. & out2<(4/obs), robust;
estadd ysumm;
drop obs out2;

eststo: probit upper c.pexp##c.pexp college in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;
eststo: margins, dydx(*) post;
eststo: reg upper c.pexp##c.pexp##c.pexp##c.pexp college in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;
eststo: reg upper c.age##c.age college in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;
eststo: reg upper c.pexp##c.pexp college in1930 i.org_code `controls_ses' if yschc40~=. & immigrant==0, robust;
estadd ysumm;
reg upper c.pexp##c.pexp college in1930 i.org_code `controls_ses' if yschc40~=.;
predict out2 if e(sample), cooksd;
gen obs=e(N);
eststo: reg upper c.pexp##c.pexp college in1930 i.org_code `controls_ses' if yschc40~=. & out2<(4/obs), robust;
estadd ysumm;
drop obs out2;

esttab using "$prog\TableA2Columns1-5.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(yschc40 college) label scalars(r2 N ymean) replace;

/* Upper Levels of Hierarchy Robustness (Cluster drops, SES interactions in instrument set, LIML, UJIVE */

est clear;
eststo ivr1: ivreg2 upper c.pexp##c.pexp (yschc40=`iv') in1930 i.org_code `controls_ses' if yschc40~=. & bplace~="PENNSYLVANIA", cluster(bplace) first savefirst savefprefix(fst1);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr2: ivreg2 upper c.pexp##c.pexp (yschc40=`iv') in1930 i.org_code `controls_ses' if yschc40~=. & bplace~="PENNSYLVANIA" & bplace~="MASSACHUSETTS", cluster(bplace) first savefirst savefprefix(fst2);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr3: ivreg2 upper c.pexp##c.pexp (yschc40=`iv_int') in1930 i.org_code `controls_ses' if yschc40~=., cluster(bplace);
estadd ysumm;;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr4: ivreg2 upper c.pexp##c.pexp (yschc40=`iv_int') in1930 i.org_code `controls_ses' if yschc40~=., cluster(bplace) liml;
estadd ysumm;;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr5: ujive upper c.pexp##c.pexp (yschc40=`iv_int') in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;

eststo ivr6: ivreg2 upper c.pexp##c.pexp (college=`iv') in1930 i.org_code `controls_ses' if yschc40~=. & bplace~="PENNSYLVANIA", cluster(bplace) first savefirst savefprefix(fst3);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr7: ivreg2 upper c.pexp##c.pexp (college=`iv') in1930 i.org_code `controls_ses' if yschc40~=. & bplace~="PENNSYLVANIA" & bplace~="MASSACHUSETTS", cluster(bplace) first savefirst savefprefix(fst4);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr8: ivreg2 upper c.pexp##c.pexp (college=`iv_int') in1930 i.org_code `controls_ses' if yschc40~=., cluster(bplace);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr9: ivreg2 upper c.pexp##c.pexp (college=`iv_int') in1930 i.org_code `controls_ses' if yschc40~=., cluster(bplace) liml;
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr10: ujive upper c.pexp##c.pexp (college=`iv_int') in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;

esttab ivr* fst* using "$prog\TableA2Columns6-10.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(yschc40 college `iv') 
label scalars(r2 N ymean MF J) sfmt(%9.3fc %9.0fc %9.3fc %9.1fc %9.3fc) replace;

/* Graphical Analysis Upper Levels of Hierarchy */

reg upper c.pexp##c.pexp i.yschc40_X in1930 i.org_code `controls_ses' if yschc40~=., robust;
margins, dydx(yschc40_X);	
marginsplot, ciopts(recast(rspike)) recast(scatter) title(" ") xtitle(Years of Education) ytitle(Effects on Pr(Upper)) ylabel(-.2(.1).3)
xlabel(1 "9" 2 "10" 3 "11" 4 "12" 5 "13" 6 "14" 7 "15" 8 "16" 9 "17", labsize(medium)) 
yline(0, lcolor(red) lwidth(thin) lpattern(dash))
graphregion(fcolor(white) lcolor(white));
graph export "$prog\Figure6.pdf", as(pdf) replace;

reg upper c.pexp##c.pexp i.yschc40_X in1930 i.org_code `controls_ses' if yschc40~=. & quart==1, robust;
margins, dydx(yschc40_X);	
marginsplot, ciopts(recast(rspike)) recast(scatter) title(" ") xtitle(Years of Education) ytitle(Effects on Pr(Upper)) ylabel(-.2(.2).6) 
xlabel(1 "9" 2 "10" 3 "11" 4 "12" 5 "13" 6 "14" 7 "15" 8 "16" 9 "17", labsize(medium)) 
yline(0, lcolor(red) lwidth(thin) lpattern(dash))
graphregion(fcolor(white) lcolor(white));
graph export "$prog\FigureA5C.pdf", as(pdf) replace;

/* Upper Levels of Hierarchy Cohorts */

reg upper c.pexp##c.pexp c.yschc40##i.quart in1930 i.org_code `controls_ses' if yschc40~=., robust;
margins, dydx(yschc40) at(quart=(1(1)4)) post;
marginsplot, ciopts(recast(rspike)) recast(scatter) title(" ") xtitle("") ytitle(Effects on Pr(Upper)) 
xlabel(1 "Cohort 1" 2 "Cohort 2" 3 "Cohort 3" 4 "Cohort 4", labsize(small)) 
graphregion(fcolor(white) lcolor(white));
graph export "$prog\FigureA5A.pdf", as(pdf) replace;

reg upper c.pexp##c.pexp i.college##i.quart in1930 i.org_code `controls_ses' if yschc40~=., robust;
margins, dydx(college) at(quart=(1(1)4)) post;
marginsplot, ciopts(recast(rspike)) recast(scatter) title(" ") xtitle("") ytitle(Effects on Pr(Upper)) 
xlabel(1 "Cohort 1" 2 "Cohort 2" 3 "Cohort 3" 4 "Cohort 4", labsize(small)) 
graphregion(fcolor(white) lcolor(white));
graph export "$prog\FigureA5B.pdf", as(pdf) replace;

/* Span of Control */

est clear;
eststo: reg span_pc_40_s c.pexp##c.pexp yschc40 if yschc40~=., robust;
estadd ysumm;
eststo: reg span_pc_40_s c.pexp##c.pexp yschc40 in1930 if yschc40~=., robust;
estadd ysumm;
eststo: reg span_pc_40_s c.pexp##c.pexp yschc40 in1930 i.org_code if yschc40~=., robust;
estadd ysumm;
eststo: reg span_pc_40_s c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;
eststo: reg span_pc_40_s c.pexp##c.pexp college if yschc40~=., robust;
estadd ysumm;
eststo: reg span_pc_40_s c.pexp##c.pexp college in1930 if yschc40~=., robust;
estadd ysumm;
eststo: reg span_pc_40_s c.pexp##c.pexp college in1930 i.org_code if yschc40~=., robust;
estadd ysumm;
eststo: reg span_pc_40_s c.pexp##c.pexp college in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;

esttab using "$prog\Table3PanelA.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(yschc40 college) label scalars(r2 N ymean) replace;

/* Span of Control (separate components) */

est clear;
eststo: reg span1_s c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' if yschc40~=. & span_pc_40_s~=., robust;
estadd ysumm;
eststo: reg span2_s c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' if yschc40~=. & span_pc_40_s~=., robust;
estadd ysumm;
eststo: reg span3_s c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' if yschc40~=. & span_pc_40_s~=., robust;
estadd ysumm;
eststo: reg span1_s c.pexp##c.pexp college in1930 i.org_code `controls_ses' if yschc40~=. & span_pc_40_s~=., robust;
estadd ysumm;
eststo: reg span2_s c.pexp##c.pexp college in1930 i.org_code `controls_ses' if yschc40~=. & span_pc_40_s~=., robust;
estadd ysumm;
eststo: reg span3_s c.pexp##c.pexp college in1930 i.org_code `controls_ses' if yschc40~=. & span_pc_40_s~=., robust;
estadd ysumm;

esttab using "$prog\TableA5.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(yschc40 college) label scalars(r2 N ymean) replace;

/* Span of Control (level 3 or above) */

est clear;
eststo: reg span_pc_40_sX c.pexp##c.pexp yschc40 if yschc40~=. & level<=3, robust;
estadd ysumm;
eststo: reg span_pc_40_sX c.pexp##c.pexp yschc40 in1930 if yschc40~=. & level<=3, robust;
estadd ysumm;
eststo: reg span_pc_40_sX c.pexp##c.pexp yschc40 in1930 i.org_code if yschc40~=. & level<=3, robust;
estadd ysumm;
eststo: reg span_pc_40_sX c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' if yschc40~=. & level<=3, robust;
estadd ysumm;
eststo: reg span_pc_40_sX c.pexp##c.pexp college if yschc40~=. & level<=3, robust;
estadd ysumm;
eststo: reg span_pc_40_sX c.pexp##c.pexp college in1930 if yschc40~=. & level<=3, robust;
estadd ysumm;
eststo: reg span_pc_40_sX c.pexp##c.pexp college in1930 i.org_code if yschc40~=. & level<=3, robust;
estadd ysumm;
eststo: reg span_pc_40_sX c.pexp##c.pexp college in1930 i.org_code `controls_ses' if yschc40~=. & level<=3, robust;
estadd ysumm;

esttab using "$prog\TableA4.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(yschc40 college) label scalars(r2 N ymean) replace;

/* Span of Control 2SLS */

est clear;
eststo ivr1: ivreg2 span_pc_40_s c.pexp##c.pexp (yschc40=`iv') if yschc40~=., cluster(bplace) first savefirst savefprefix(fst1);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr2: ivreg2 span_pc_40_s c.pexp##c.pexp (yschc40=`iv') in1930 if yschc40~=., cluster(bplace) first savefirst savefprefix(fst2);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr3: ivreg2 span_pc_40_s c.pexp##c.pexp (yschc40=`iv') in1930 i.org_code if yschc40~=., cluster(bplace) first savefirst savefprefix(fst3);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr4: ivreg2 span_pc_40_s c.pexp##c.pexp (yschc40=`iv') in1930 i.org_code `controls_ses' if yschc40~=., cluster(bplace) first savefirst savefprefix(fst4);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr5: ivreg2 span_pc_40_s c.pexp##c.pexp (college=`iv') if yschc40~=., cluster(bplace) first savefirst savefprefix(fst5);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr6: ivreg2 span_pc_40_s c.pexp##c.pexp (college=`iv') in1930 if yschc40~=., cluster(bplace) first savefirst savefprefix(fst6);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr7: ivreg2 span_pc_40_s c.pexp##c.pexp (college=`iv') in1930 i.org_code if yschc40~=., cluster(bplace) first savefirst savefprefix(fst7);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr8: ivreg2 span_pc_40_s c.pexp##c.pexp (college=`iv') in1930 i.org_code `controls_ses' if yschc40~=., cluster(bplace) first savefirst savefprefix(fst8);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

esttab ivr* fst* using "$prog\Table3PanelB.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(yschc40 college `iv') 
label scalars(r2 N ymean MF J) sfmt(%9.3fc %9.0fc %9.3fc %9.1fc %9.3fc) replace;

/* Span of Control Robustness */

est clear;
eststo: reg span_pc_40_s c.pexp##c.pexp##c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;
eststo: reg span_pc_40_s c.age##c.age yschc40 in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;
eststo: reg span_pc_40_s c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' if yschc40~=. & immigrant==0, robust;
estadd ysumm;
reg span_pc_40_s c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' if yschc40~=.;
predict out2 if e(sample), cooksd;
gen obs=e(N);
eststo: reg span_pc_40_s c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' if yschc40~=. & out2<(4/obs), robust;
estadd ysumm;
drop obs out2;

eststo: reg span_pc_40_s c.pexp##c.pexp##c.pexp##c.pexp college in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;
eststo: reg span_pc_40_s c.age##c.age college in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;
eststo: reg span_pc_40_s c.pexp##c.pexp college in1930 i.org_code `controls_ses' if yschc40~=. & immigrant==0, robust;
estadd ysumm;
reg span_pc_40_s c.pexp##c.pexp college in1930 i.org_code `controls_ses' if yschc40~=.;
predict out2 if e(sample), cooksd;
gen obs=e(N);
eststo: reg span_pc_40_s c.pexp##c.pexp college in1930 i.org_code `controls_ses' if yschc40~=. & out2<(4/obs), robust;
estadd ysumm;
drop obs out2;

esttab using "$prog\TableA3Columns1-4.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(yschc40 college) label scalars(r2 N ymean) replace;

/* Span of Control Robustness (Cluster drops, SES interactions in instrument set, LIML, UJIVE */

est clear;
eststo ivr1: ivreg2 span_pc_40_s c.pexp##c.pexp (yschc40=`iv') in1930 i.org_code `controls_ses' if yschc40~=. & bplace~="PENNSYLVANIA", cluster(bplace) first savefirst savefprefix(fst1);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr2: ivreg2 span_pc_40_s c.pexp##c.pexp (yschc40=`iv') in1930 i.org_code `controls_ses' if yschc40~=. & bplace~="PENNSYLVANIA" & bplace~="MASSACHUSETTS", cluster(bplace) first savefirst savefprefix(fst2);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr3: ivreg2 span_pc_40_s c.pexp##c.pexp (yschc40=`iv_int') in1930 i.org_code `controls_ses' if yschc40~=., cluster(bplace);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr4: ivreg2 span_pc_40_s c.pexp##c.pexp (yschc40=`iv_int') in1930 i.org_code `controls_ses' if yschc40~=., cluster(bplace) liml;
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr5: ujive span_pc_40_s c.pexp##c.pexp (yschc40=`iv_int') in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;

eststo ivr6: ivreg2 span_pc_40_s c.pexp##c.pexp (college=`iv') in1930 i.org_code `controls_ses' if yschc40~=. & bplace~="PENNSYLVANIA", cluster(bplace) first savefirst savefprefix(fst3);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr7: ivreg2 span_pc_40_s c.pexp##c.pexp (college=`iv') in1930 i.org_code `controls_ses' if yschc40~=. & bplace~="PENNSYLVANIA" & bplace~="MASSACHUSETTS", cluster(bplace) first savefirst savefprefix(fst4);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr8: ivreg2 span_pc_40_s c.pexp##c.pexp (college=`iv_int') in1930 i.org_code `controls_ses' if yschc40~=., cluster(bplace);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr9: ivreg2 span_pc_40_s c.pexp##c.pexp (college=`iv_int') in1930 i.org_code `controls_ses' if yschc40~=., cluster(bplace) liml;
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr10: ujive span_pc_40_s c.pexp##c.pexp (college=`iv_int') in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;

esttab ivr* fst* using "$prog\TableA3Columns5-9.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(yschc40 college `iv') 
label scalars(r2 N ymean MF J) sfmt(%9.3fc %9.0fc %9.3fc %9.1fc %9.3fc) replace;

/* Graphical Analysis Span of Control */

reg span_pc_40_s c.pexp##c.pexp i.yschc40_X in1930 i.org_code `controls_ses' if yschc40~=., robust;
margins, dydx(yschc40_X);	
marginsplot, ciopts(recast(rspike)) recast(scatter) title(" ") xtitle(Years of Education) ytitle(Effects on Span of Control) ylabel(-.5(.25)1.0)
xlabel(1 "9" 2 "10" 3 "11" 4 "12" 5 "13" 6 "14" 7 "15" 8 "16" 9 "17", labsize(medium)) 
yline(0, lcolor(red) lwidth(thin) lpattern(dash))
graphregion(fcolor(white) lcolor(white));
graph export "$prog\Figure7.pdf", as(pdf) replace;

reg span_pc_40_s c.pexp##c.pexp i.yschc40_X in1930 i.org_code `controls_ses' if yschc40~=. & quart==1, robust;
margins, dydx(yschc40_X);	
marginsplot, ciopts(recast(rspike)) recast(scatter) title(" ") xtitle(Years of Education) ytitle(Effects on Span of Control) ylabel(-1(1)3) 
xlabel(1 "9" 2 "10" 3 "11" 4 "12" 5 "13" 6 "14" 7 "15" 8 "16" 9 "17", labsize(medium)) 
yline(0, lcolor(red) lwidth(thin) lpattern(dash))
graphregion(fcolor(white) lcolor(white));
graph export "$prog\FigureA6C.pdf", as(pdf) replace;

/* Span of Control Cohorts */

reg span_pc_40_s c.pexp##c.pexp c.yschc40##i.quart in1930 i.org_code `controls_ses' if yschc40~=., robust;
margins, dydx(yschc40) at(quart=(1(1)4)) post;
marginsplot, ciopts(recast(rspike)) recast(scatter) title(" ") xtitle("") ytitle(Effects on Span of Control) 
xlabel(1 "Cohort 1" 2 "Cohort 2" 3 "Cohort 3" 4 "Cohort 4", labsize(small)) 
graphregion(fcolor(white) lcolor(white));
graph export "$prog\FigureA6A.pdf", as(pdf) replace;

reg span_pc_40_s c.pexp##c.pexp i.college##i.quart in1930 i.org_code `controls_ses' if yschc40~=., robust;
margins, dydx(college) at(quart=(1(1)4)) post;
marginsplot, ciopts(recast(rspike)) recast(scatter) title(" ") xtitle("") ytitle(Effects on Span of Control) 
xlabel(1 "Cohort 1" 2 "Cohort 2" 3 "Cohort 3" 4 "Cohort 4", labsize(small)) 
graphregion(fcolor(white) lcolor(white));
graph export "$prog\FigureA6B.pdf", as(pdf) replace;

/* Wages */

est clear;
eststo: reg lwageW c.pexp##c.pexp yschc40 if yschc40~=., robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp yschc40 in1930 if yschc40~=., robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp yschc40 in1930 i.org_code if yschc40~=., robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp college if yschc40~=., robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp college in1930 if yschc40~=., robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp college in1930 i.org_code if yschc40~=., robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp college in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp college in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
estadd ysumm;

esttab using "$prog\Table4PanelA.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(yschc40 college) label scalars(r2 N ymean) replace;

/* Wages 2SLS */

est clear;
eststo ivr1: ivreg2 lwageW c.pexp##c.pexp (yschc40=`iv') if yschc40~=., cluster(bplace) first savefirst savefprefix(fst1);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr2: ivreg2 lwageW c.pexp##c.pexp (yschc40=`iv') in1930 if yschc40~=., cluster(bplace) first savefirst savefprefix(fst2);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr3: ivreg2 lwageW c.pexp##c.pexp (yschc40=`iv') in1930 i.org_code if yschc40~=., cluster(bplace) first savefirst savefprefix(fst3);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr4: ivreg2 lwageW c.pexp##c.pexp (yschc40=`iv') in1930 i.org_code `controls_ses' if yschc40~=., cluster(bplace) first savefirst savefprefix(fst4);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr5: ivreg2 lwageW c.pexp##c.pexp (yschc40=`iv') in1930 i.org_code `controls_ses' i.level if yschc40~=., cluster(bplace) first savefirst savefprefix(fst5);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr6: ivreg2 lwageW c.pexp##c.pexp (college=`iv') if yschc40~=., cluster(bplace) first savefirst savefprefix(fst6);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr7: ivreg2 lwageW c.pexp##c.pexp (college=`iv') in1930 if yschc40~=., cluster(bplace) first savefirst savefprefix(fst7);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr8: ivreg2 lwageW c.pexp##c.pexp (college=`iv') in1930 i.org_code if yschc40~=., cluster(bplace) first savefirst savefprefix(fst8);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr9: ivreg2 lwageW c.pexp##c.pexp (college=`iv') in1930 i.org_code `controls_ses' if yschc40~=., cluster(bplace) first savefirst savefprefix(fst9);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr10: ivreg2 lwageW c.pexp##c.pexp (college=`iv') in1930 i.org_code `controls_ses' i.level if yschc40~=., cluster(bplace) first savefirst savefprefix(fst10);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

esttab ivr* fst* using "$prog\Table4PanelB.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(yschc40 college `iv') 
label scalars(r2 N ymean MF J) sfmt(%9.3fc %9.0fc %9.3fc %9.1fc %9.3fc) replace;

/* Wages Robustness */

est clear;
eststo: reg lwageW c.pexp##c.pexp##c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
estadd ysumm;
eststo: reg lwageW c.age##c.age yschc40 in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' i.level if yschc40~=. & immigrant==0, robust;
estadd ysumm;
reg lwageW c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' i.level if yschc40~=.;
predict out2 if e(sample), cooksd;
gen obs=e(N);
eststo: reg lwageW c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' i.level if yschc40~=. & out2<(4/obs), robust;
estadd ysumm;
drop obs out2;

eststo: reg lwageW c.pexp##c.pexp##c.pexp##c.pexp college in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
estadd ysumm;
eststo: reg lwageW c.age##c.age college in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp college in1930 i.org_code `controls_ses' i.level if yschc40~=. & immigrant==0, robust;
estadd ysumm;
reg lwageW c.pexp##c.pexp college in1930 i.org_code `controls_ses' i.level if yschc40~=.;
predict out2 if e(sample), cooksd;
gen obs=e(N);
eststo: reg lwageW c.pexp##c.pexp college in1930 i.org_code `controls_ses' i.level if yschc40~=. & out2<(4/obs), robust;
estadd ysumm;
drop obs out2;

esttab using "$prog\TableA6Columns1-4.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(yschc40 college) label scalars(r2 N ymean) replace;

/* Wages Robustness (Cluster drops, SES interactions in instrument set, LIML, UJIVE */

eststo ivr1: ivreg2 lwageW c.pexp##c.pexp (yschc40=`iv') in1930 i.org_code `controls_ses' i.level if yschc40~=. & bplace~="PENNSYLVANIA", cluster(bplace) first savefirst savefprefix(fst1);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr2: ivreg2 lwageW c.pexp##c.pexp (yschc40=`iv') in1930 i.org_code `controls_ses' i.level if yschc40~=. & bplace~="PENNSYLVANIA" & bplace~="MASSACHUSETTS", cluster(bplace) first savefirst savefprefix(fst2);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr3: ivreg2 lwageW c.pexp##c.pexp (yschc40=`iv_int') in1930 i.org_code `controls_ses' i.level if yschc40~=., cluster(bplace);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr4: ivreg2 lwageW c.pexp##c.pexp (yschc40=`iv_int') in1930 i.org_code `controls_ses' i.level if yschc40~=., cluster(bplace) liml;
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr5: ujive lwageW c.pexp##c.pexp (yschc40=`iv_int') in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
estadd ysumm;

eststo ivr6: ivreg2 lwageW c.pexp##c.pexp (college=`iv') in1930 i.org_code `controls_ses' i.level if yschc40~=. & bplace~="PENNSYLVANIA", cluster(bplace) first savefirst savefprefix(fst3);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr7: ivreg2 lwageW c.pexp##c.pexp (college=`iv') in1930 i.org_code `controls_ses' i.level if yschc40~=. & bplace~="PENNSYLVANIA" & bplace~="MASSACHUSETTS", cluster(bplace) first savefirst savefprefix(fst4);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr8: ivreg2 lwageW c.pexp##c.pexp (college=`iv_int') in1930 i.org_code `controls_ses' i.level if yschc40~=., cluster(bplace);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr9: ivreg2 lwageW c.pexp##c.pexp (college=`iv_int') in1930 i.org_code `controls_ses' i.level if yschc40~=., cluster(bplace) liml;
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr10: ujive lwageW c.pexp##c.pexp (college=`iv_int') in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
estadd ysumm;

esttab ivr* fst* using "$prog\TableA6Columns5-9.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(yschc40 college `iv') 
label scalars(r2 N ymean MF J) sfmt(%9.3fc %9.0fc %9.3fc %9.1fc %9.3fc) replace;

/* Wages - Dropping Top Coded */

est clear;
eststo: reg lwageW c.pexp##c.pexp yschc40 if yschc40~=. & lwageW<=4.565949, robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp yschc40 in1930 if yschc40~=. & lwageW<=4.565949, robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp yschc40 in1930 i.org_code if yschc40~=. & lwageW<=4.565949, robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' if yschc40~=. & lwageW<=4.565949, robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' i.level if yschc40~=. & lwageW<=4.565949, robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp college if yschc40~=. & lwageW<=4.565949, robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp college in1930 if yschc40~=. & lwageW<=4.565949, robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp college in1930 i.org_code if yschc40~=. & lwageW<=4.565949, robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp college in1930 i.org_code `controls_ses' if yschc40~=. & lwageW<=4.565949, robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp college in1930 i.org_code `controls_ses' i.level if yschc40~=. & lwageW<=4.565949, robust;
estadd ysumm;

esttab using "$prog\Table5PanelA.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(yschc40 college) label scalars(r2 N ymean) replace;

/* Wages - Tobit */

est clear;
eststo: tobit lwageW c.pexp##c.pexp yschc40 if yschc40~=., ul(4.565949) vce(robust);
estadd ysumm;
estadd scalar R=e(N_rc);
eststo: tobit lwageW c.pexp##c.pexp yschc40 in1930 if yschc40~=., ul(4.565949) vce(robust);
estadd ysumm;
estadd scalar R=e(N_rc);
eststo: tobit lwageW c.pexp##c.pexp yschc40 in1930 i.org_code if yschc40~=., ul(4.565949) vce(robust);
estadd ysumm;
estadd scalar R=e(N_rc);
eststo: tobit lwageW c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' if yschc40~=., ul(4.565949) vce(robust);
estadd ysumm;
estadd scalar R=e(N_rc);
eststo: tobit lwageW c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' i.level if yschc40~=., ul(4.565949) vce(robust);
estadd ysumm;
estadd scalar R=e(N_rc);
eststo: tobit lwageW c.pexp##c.pexp college if yschc40~=., ul(4.565949) vce(robust);
estadd ysumm;
estadd scalar R=e(N_rc);
eststo: tobit lwageW c.pexp##c.pexp college in1930 if yschc40~=., ul(4.565949) vce(robust);
estadd ysumm;
estadd scalar R=e(N_rc);
eststo: tobit lwageW c.pexp##c.pexp college in1930 i.org_code if yschc40~=., ul(4.565949) vce(robust);
estadd ysumm;
estadd scalar R=e(N_rc);
eststo: tobit lwageW c.pexp##c.pexp college in1930 i.org_code `controls_ses' if yschc40~=., ul(4.565949) vce(robust);
estadd ysumm;
estadd scalar R=e(N_rc);
eststo: tobit lwageW c.pexp##c.pexp college in1930 i.org_code `controls_ses' i.level if yschc40~=., ul(4.565949) vce(robust);
estadd ysumm;
estadd scalar R=e(N_rc);

esttab using "$prog\Table5PanelB.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(yschc40 college) label scalars(N ymean R) sfmt(%9.0fc %9.3fc %9.0fc) replace;

/* Wages - Imputing */

est clear;
eststo: bootstrap, reps(1000) seed(4321) cluster(level): reg lwage_impW c.pexp##c.pexp yschc40 if yschc40~=., cluster(level);
estadd ysumm;
eststo: bootstrap, reps(1000) seed(4321) cluster(level): reg lwage_impW c.pexp##c.pexp yschc40 in1930 if yschc40~=., cluster(level);
estadd ysumm;
eststo: bootstrap, reps(1000) seed(4321) cluster(level): reg lwage_impW c.pexp##c.pexp yschc40 in1930 i.org_code if yschc40~=., cluster(level);
estadd ysumm;
eststo: bootstrap, reps(1000) seed(4321) cluster(level): reg lwage_impW c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' if yschc40~=., cluster(level);
estadd ysumm;
eststo: bootstrap, reps(1000) seed(4321) cluster(level): reg lwage_impW c.pexp##c.pexp college if yschc40~=., cluster(level);
estadd ysumm;
eststo: bootstrap, reps(1000) seed(4321) cluster(level): reg lwage_impW c.pexp##c.pexp college in1930 if yschc40~=., cluster(level);
estadd ysumm;
eststo: bootstrap, reps(1000) seed(4321): reg lwage_impW c.pexp##c.pexp college in1930 i.org_code if yschc40~=., cluster(level);
estadd ysumm;
eststo: bootstrap, reps(1000) seed(4321) cluster(level): reg lwage_impW c.pexp##c.pexp college in1930 i.org_code `controls_ses' if yschc40~=., cluster(level);
estadd ysumm;

esttab using "$prog\Table5PanelC.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(yschc40 college) label scalars(r2 N ymean) replace;

/* Graphical Analysis Wages */

reg lwageW c.pexp##c.pexp i.yschc40_X in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
margins, dydx(yschc40_X);	
marginsplot, ciopts(recast(rspike)) recast(scatter) title(" ") xtitle(Years of Education) ytitle(Effects on Log Weekly Wages) 
ylabel(-.25(.25).75)
xlabel(1 "9" 2 "10" 3 "11" 4 "12" 5 "13" 6 "14" 7 "15" 8 "16" 9 "17", labsize(medium)) 
yline(0, lcolor(red) lwidth(thin) lpattern(dash))
graphregion(fcolor(white) lcolor(white));
graph export "$prog\Figure8.pdf", as(pdf) replace;

reg lwageW c.pexp##c.pexp i.yschc40_X in1930 i.org_code `controls_ses' i.level if yschc40~=. & quart>=3, robust;
margins, dydx(yschc40_X);	
marginsplot, ciopts(recast(rspike)) recast(scatter) title(" ") xtitle(Years of Education) ytitle(Effects on Log Weekly Wages) 
xlabel(1 "9" 2 "10" 3 "11" 4 "12" 5 "13" 6 "14" 7 "15" 8 "16" 9 "17", labsize(medium)) 
yline(0, lcolor(red) lwidth(thin) lpattern(dash))
graphregion(fcolor(white) lcolor(white));
graph export "$prog\FigureA7C.pdf", as(pdf) replace;

/* Wages Cohorts */

reg lwageW c.pexp##c.pexp c.yschc40##i.quart in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
margins, dydx(yschc40) at(quart=(1(1)4)) post;
marginsplot, ciopts(recast(rspike)) recast(scatter) title(" ") xtitle("") ytitle(Effects on Log Weekly Wages) 
xlabel(1 "Cohort 1" 2 "Cohort 2" 3 "Cohort 3" 4 "Cohort 4", labsize(small))
graphregion(fcolor(white) lcolor(white));
graph export "$prog\FigureA7A.pdf", as(pdf) replace;

reg lwageW c.pexp##c.pexp i.college##i.quart in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
margins, dydx(college) at(quart=(1(1)4)) post;
marginsplot, ciopts(recast(rspike)) recast(scatter) title(" ") xtitle("") ytitle(Effects on Log Weekly Wages) 
xlabel(1 "Cohort 1" 2 "Cohort 2" 3 "Cohort 3" 4 "Cohort 4", labsize(small)) 
graphregion(fcolor(white) lcolor(white));
graph export "$prog\FigureA7B.pdf", as(pdf) replace;

/* Management Training */

est clear;
eststo: reg cg2 c.pexp##c.pexp yschc40 if yschc40~=., robust;
estadd ysumm;
eststo: reg cg2 c.pexp##c.pexp yschc40 in1930 if yschc40~=., robust;
estadd ysumm;
eststo: reg cg2 c.pexp##c.pexp yschc40 in1930 i.org_code if yschc40~=., robust;
estadd ysumm;
eststo: reg cg2 c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;
eststo: reg cg2 c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
estadd ysumm;
eststo: reg cg2 c.pexp##c.pexp college if yschc40~=., robust;
estadd ysumm;
eststo: reg cg2 c.pexp##c.pexp college in1930 if yschc40~=., robust;
estadd ysumm;
eststo: reg cg2 c.pexp##c.pexp college in1930 i.org_code if yschc40~=., robust;
estadd ysumm;
eststo: reg cg2 c.pexp##c.pexp college in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;
eststo: reg cg2 c.pexp##c.pexp college in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
estadd ysumm;

esttab using "$prog\Table6PanelA.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(yschc40 college) label scalars(r2 N ymean) replace;

/* Management Training 2SLS */

est clear;
eststo ivr1: ivreg2 cg2 c.pexp##c.pexp (yschc40=`iv') if yschc40~=., cluster(bplace) first savefirst savefprefix(fst1);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr2: ivreg2 cg2 c.pexp##c.pexp (yschc40=`iv') in1930 if yschc40~=., cluster(bplace) first savefirst savefprefix(fst2);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr3: ivreg2 cg2 c.pexp##c.pexp (yschc40=`iv') in1930 i.org_code if yschc40~=., cluster(bplace) first savefirst savefprefix(fst3);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr4: ivreg2 cg2 c.pexp##c.pexp (yschc40=`iv') in1930 i.org_code `controls_ses' if yschc40~=., cluster(bplace) first savefirst savefprefix(fst4);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr5: ivreg2 cg2 c.pexp##c.pexp (yschc40=`iv') in1930 i.org_code `controls_ses' i.level if yschc40~=., cluster(bplace) first savefirst savefprefix(fst5);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr6: ivreg2 cg2 c.pexp##c.pexp (college=`iv') if yschc40~=., cluster(bplace) first savefirst savefprefix(fst6);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr7: ivreg2 cg2 c.pexp##c.pexp (college=`iv') in1930 if yschc40~=., cluster(bplace) first savefirst savefprefix(fst7);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr8: ivreg2 cg2 c.pexp##c.pexp (college=`iv') in1930 i.org_code if yschc40~=., cluster(bplace) first savefirst savefprefix(fst8);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr9: ivreg2 cg2 c.pexp##c.pexp (college=`iv') in1930 i.org_code `controls_ses' if yschc40~=., cluster(bplace) first savefirst savefprefix(fst9);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr10: ivreg2 cg2 c.pexp##c.pexp (college=`iv') in1930 i.org_code `controls_ses' i.level if yschc40~=., cluster(bplace) first savefirst savefprefix(fst10);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

esttab ivr* fst* using "$prog\Table6PanelB.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(yschc40 college `iv') 
label scalars(r2 N ymean MF J) sfmt(%9.3fc %9.0fc %9.3fc %9.1fc %9.3fc) replace;

/* Management Training Robustness */

est clear;
eststo: poisson cg c.pexp##c.pexp##c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
estadd ysumm;
eststo: reg cg2 c.pexp##c.pexp##c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
estadd ysumm;
eststo: reg cg2 c.age##c.age yschc40 in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
estadd ysumm;
eststo: reg cg2 c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' i.level if yschc40~=. & immigrant==0, robust;
estadd ysumm;
reg cg2 c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' i.level if yschc40~=.;
predict out2 if e(sample), cooksd;
gen obs=e(N);
eststo: reg cg2 c.pexp##c.pexp yschc40 in1930 i.org_code `controls_ses' i.level if yschc40~=. & out2<(4/obs), robust;
estadd ysumm;
drop obs out2;

eststo: poisson cg c.pexp##c.pexp##c.pexp##c.pexp college in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
estadd ysumm;
eststo: reg cg2 c.pexp##c.pexp##c.pexp##c.pexp college in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
estadd ysumm;
eststo: reg cg2 c.age##c.age college in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
estadd ysumm;
eststo: reg cg2 c.pexp##c.pexp college in1930 i.org_code `controls_ses' i.level if yschc40~=. & immigrant==0, robust;
estadd ysumm;
reg cg2 c.pexp##c.pexp college in1930 i.org_code `controls_ses' i.level if yschc40~=.;
predict out2 if e(sample), cooksd;
gen obs=e(N);
eststo: reg cg2 c.pexp##c.pexp college in1930 i.org_code `controls_ses' i.level if yschc40~=. & out2<(4/obs), robust;
estadd ysumm;
drop obs out2;

esttab using "$prog\TableA7Columns1-5.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(yschc40 college) label scalars(r2 N ymean) replace;

/* Management Training Robustness (Cluster drops, SES interactions in instrument set, LIML, UJIVE */

est clear;
eststo ivr1: ivreg2 cg2 c.pexp##c.pexp (yschc40=`iv') in1930 i.org_code `controls_ses' i.level if yschc40~=. & bplace~="PENNSYLVANIA", cluster(bplace) first savefirst savefprefix(fst1);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr2: ivreg2 cg2 c.pexp##c.pexp (yschc40=`iv') in1930 i.org_code `controls_ses' i.level if yschc40~=. & bplace~="PENNSYLVANIA" & bplace~="MASSACHUSETTS", cluster(bplace) first savefirst savefprefix(fst2);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr3: ivreg2 cg2 c.pexp##c.pexp (yschc40=`iv_int') in1930 i.org_code `controls_ses' i.level if yschc40~=., cluster(bplace);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr4: ivreg2 cg2 c.pexp##c.pexp (yschc40=`iv_int') in1930 i.org_code `controls_ses' i.level if yschc40~=., cluster(bplace) liml;
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr5: ujive cg2 c.pexp##c.pexp (yschc40=`iv_int') in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
estadd ysumm;

eststo ivr6: ivreg2 cg2 c.pexp##c.pexp (college=`iv') in1930 i.org_code `controls_ses' i.level if yschc40~=. & bplace~="PENNSYLVANIA", cluster(bplace) first savefirst savefprefix(fst3);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr7: ivreg2 cg2 c.pexp##c.pexp (college=`iv') in1930 i.org_code `controls_ses' i.level if yschc40~=. & bplace~="PENNSYLVANIA" & bplace~="MASSACHUSETTS", cluster(bplace) first savefirst savefprefix(fst4);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr8: ivreg2 cg2 c.pexp##c.pexp (college=`iv_int') in1930 i.org_code `controls_ses' i.level if yschc40~=., cluster(bplace);
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr9: ivreg2 cg2 c.pexp##c.pexp (college=`iv_int') in1930 i.org_code `controls_ses' i.level if yschc40~=., cluster(bplace) liml;
estadd ysumm;
estadd scalar J=e(jp);
weakivtest;
mat fstat=r(F_eff);
estadd scalar MF=fstat[1,1];

eststo ivr10: ujive cg2 c.pexp##c.pexp (college=`iv_int') in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
estadd ysumm;

esttab ivr* fst* using "$prog\TableA7Columns6-10.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(yschc40 college `iv') 
label scalars(r2 N ymean MF J) sfmt(%9.3fc %9.0fc %9.3fc %9.1fc %9.3fc) replace;

/* Graphical Analysis Management Training */

reg cg2 c.pexp##c.pexp i.yschc40_X in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
margins, dydx(yschc40_X);	
marginsplot, ciopts(recast(rspike)) recast(scatter) title(" ") xtitle(Years of Education) ytitle(Effects on Pr(Management Training)) 
xlabel(1 "9" 2 "10" 3 "11" 4 "12" 5 "13" 6 "14" 7 "15" 8 "16" 9 "17", labsize(medium)) 
yline(0, lcolor(red) lwidth(thin) lpattern(dash))
graphregion(fcolor(white) lcolor(white));
graph export "$prog\Figure9.pdf", as(pdf) replace;

reg cg2 c.pexp##c.pexp i.yschc40_X in1930 i.org_code `controls_ses' i.level if yschc40~=. & quart==1, robust;
margins, dydx(yschc40_X);	
marginsplot, ciopts(recast(rspike)) recast(scatter) title(" ") xtitle(Years of Education) ytitle(Effects on Pr(Management Training)) 
xlabel(1 "9" 2 "10" 3 "11" 4 "12" 5 "13" 6 "14" 7 "15" 8 "16" 9 "17", labsize(medium)) 
yline(0, lcolor(red) lwidth(thin) lpattern(dash))
graphregion(fcolor(white) lcolor(white));
graph export "$prog\FigureA8C.pdf", as(pdf) replace;

/* Management Training Cohorts */

reg cg2 c.pexp##c.pexp c.yschc40##i.quart in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
margins, dydx(yschc40) at(quart=(1(1)4)) post;
marginsplot, ciopts(recast(rspike)) recast(scatter) title(" ") xtitle("") ytitle(Effects on Pr(Management Training)) 
xlabel(1 "Cohort 1" 2 "Cohort 2" 3 "Cohort 3" 4 "Cohort 4", labsize(small))
graphregion(fcolor(white) lcolor(white));
graph export "$prog\FigureA8A.pdf", as(pdf) replace;

reg cg2 c.pexp##c.pexp i.college##i.quart in1930 i.org_code `controls_ses' i.level if yschc40~=., robust;
margins, dydx(college) at(quart=(1(1)4)) post;
marginsplot, ciopts(recast(rspike)) recast(scatter) title(" ") xtitle("") ytitle(Effects on Pr(Management Training)) 
xlabel(1 "Cohort 1" 2 "Cohort 2" 3 "Cohort 3" 4 "Cohort 4", labsize(small)) 
graphregion(fcolor(white) lcolor(white));
graph export "$prog\FigureA8B.pdf", as(pdf) replace;

/* Education and Management Training */

est clear;
eststo: reg upper c.pexp##c.pexp cg2 in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;
eststo: reg upper c.pexp##c.pexp yschc40 cg2 in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;
eststo: reg upper c.pexp##c.pexp college cg2 in1930 i.org_code `controls_ses' if yschc40~=., robust;
estadd ysumm;

eststo: reg lwageW c.pexp##c.pexp cg2 in1930 i.org_code i.level `controls_ses' if yschc40~=., robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp yschc40 cg2 in1930 i.org_code i.level `controls_ses' if yschc40~=., robust;
estadd ysumm;
eststo: reg lwageW c.pexp##c.pexp college cg2 in1930 i.org_code i.level `controls_ses' if yschc40~=., robust;
estadd ysumm;

eststo: tobit lwageW c.pexp##c.pexp cg2 in1930 i.org_code i.level `controls_ses' if yschc40~=., ul(4.565949) vce(robust);
estadd ysumm;
eststo: tobit lwageW c.pexp##c.pexp yschc40 cg2 in1930 i.org_code i.level `controls_ses' if yschc40~=., ul(4.565949) vce(robust);
estadd ysumm;
eststo: tobit lwageW c.pexp##c.pexp college cg2 in1930 i.org_code i.level `controls_ses' if yschc40~=., ul(4.565949) vce(robust);
estadd ysumm;

esttab using "$prog\Table7.csv", b(3) se(3) nocons star(* 0.10 ** 0.05 *** 0.01) keep(cg2 yschc40 college) label scalars(r2 N ymean) replace;

log close;